

class TransformNode {

    constructor(nodes) {

        this.v=new Array();
        this.vr=new Array();


        for(let i=0;i<nodes.length;i++){
            let node=nodes[i];
            this.v.push(node.id);
            for(let l=0;l<node.inputs.length;l++){
                let input = node.inputs[l];

                if(  typeof input.connection === 'undefined') continue;
                for(let n=0;n< input.connection.length;n++){
                    let connection = input.connection.[n];

                    let vr= [node.id,connection.nodeId,1]
                    this.vr.push(vr)
                }

            }
        }
    }
    find(){

    }
    run(){
        let _this=this;
        let nodes=new Array();
        for(let i=0;i<this.stack.length;i++){

            let stackElement = this.stack[i];
            let node=this.find(stackElement);

            let inputs=node.inputs;
            for(let l=0;l<inputs.length;l++){
                let input=inputs[l];

                let inputData=new Array();
                for(let n=0;n<input.length;n++){
                    let connection=  input[n];
                    let nodeName=connection.nodeId;
                    let port=connection.port;
                    let  nodeId= this.find(nodeName);
                    let outputData = _this.nodes[nodeId].data.output[port];
                    inputData.push(outputData)

                }
                node.data.input[l]=inputData;
            }
            node.run();
            nodes.push(node);
        }
        this.data.input[0]=nodes;
    }

    seaveSotr( stack){
        this.stack=stack;
    }

}

export default  TransformNode;
